package com.sts.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.sts.bean.Base_eq;

@Repository
public class Base_eqDao implements IBase_eqDao{
	
	
	@Resource
	private SqlSessionFactory sqlSessionFactory;
	
	Logger log = Logger.getLogger(this.getClass());

	/**
	 * 插入一条数据
	 */
	@Override
	public int insertBase_eq(Base_eq bs) {
		int result = 0;
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		result = Iba.insertBase_eq(bs) ;
		return result;
	}

	/**
	 * 查询所有的设备
	 */
	@Override
	public List<Base_eq> selectBase_eq() {
		List<Base_eq> list = new ArrayList<Base_eq>();
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		list = Iba.selectBase_eq();

		return list;
	}

	/**
	 * 删除信息，撤销功能
	 */
	@Override
	public int deleteById() {
		int result = 0;
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		result = Iba.deleteById() ;
		return result;
	}

	/**
	 * 重置功能
	 */
	@Override
	public int deleteAll() {
		int result = 0;
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		result = Iba.deleteAll() ;
		return result;
	}

	@Override
	public Base_eq selectBase_eqById(int eq_id) {
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		
		Base_eq base_eq = Iba.selectBase_eqById(eq_id);
		return base_eq;
	}

	@Override
	public List<Base_eq> selectEqMsg(Map<String, Object> map) {
		List<Base_eq> list = new ArrayList<Base_eq>();
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		list = Iba.selectEqMsg(map) ;
		return list;
	}

	@Override
	public int selectEqNum(Map<String, Object> map) {
		int num = 0 ;
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		num = Iba.selectEqNum(map) ;
		return num;
	}

	@Override
	public List<Integer> selectEqID() {
		List<Integer> list = new ArrayList<Integer>() ;
		SqlSession session = sqlSessionFactory.openSession();
		IBase_eqDao Iba = session.getMapper(IBase_eqDao.class);
		list = Iba.selectEqID();
		
		return list;
	}
	
	/**
	 * 查出所有的设备ID
	 * 
	 */
	
	

}
